class type modulator_type =
object
  method signal: float -> float
end
 
class dummy_modulator =
object
 method signal (t:float) = 0.
end


class simple_add m1 m2 =
object
  val mod1 = m1
  val mod2 = m2
  method signal (t:float) = 
	( (m1#signal t) +. (m2#signal t) ) /. 2.
end


class ['a] additive n =
object
  val mutable nb_mods = 0
  val tab: 'a array = Array.make n (new dummy_modulator)

  method add (m:'a) = 
	tab.(nb_mods) 	<- m;
	nb_mods 	<- nb_mods + 1

  method signal t = 
	let i = ref (0) and s = ref (0.)in
	while !i < nb_mods do
		s := !s +. (tab.(!i)#signal t);
		i := !i + 1
	done;
	s := !s /. (float_of_int nb_mods);
	!s
end


let dummy_mod =
object
  method signal (t:float) = 0.
end

